package cn.lesaas.esb.poc.route;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.JavaUuidGenerator;
import org.springframework.stereotype.Component;

public class SqlRoute extends RouteBuilder{

	@Override
	public void configure() throws Exception {
		from("direct:sql")
		.transacted()
		.setHeader("sequence").method(JavaUuidGenerator.class, "generateUuid").to("mock:out")
		.to("sql:update jobs set state=1, sequence=:#sequence where state=0 and UNIX_TIMESTAMP() - UNIX_TIMESTAMP(startTimestamp)  > duration")
		.to("sql:select message from jobs where sequence=:#sequence")
		.to("mock:result");
	}
}
